(function () {
    'use strict';

    angular
        .module('app.refs')
        .controller('referralController', referralController);

    referralController.$inject = ['logger', '$state', '$rootScope', '$stateParams', 'UserReferralData'];
    /* @ngInject */
    function referralController(logger, $state, $rootScope, $stateParams, UserReferralData) {
        var vm = this;
        vm.title = 'referral';
        vm.user = $stateParams.Category;
        vm.password = "";
        vm.colors = "altTheme1";
        vm.SectionClick = SectionClick;
        var ReferralType = $stateParams.Category;
        
        if (ReferralType == 'New' || ReferralType == 'Referral-In') {
            vm.ReferralGroups = UserReferralData.GetNewReferrals();
        }
        else if (ReferralType == 'In Process' ) {
            vm.ReferralGroups = UserReferralData.GetOutstandingReferrals();
        }
        else if (ReferralType == 'Scheduled') {
            vm.ReferralGroups = UserReferralData.GetScheduledReferrals();
        }
        else if (ReferralType == 'Completed' || ReferralType == 'Referral-Out') {
            vm.ReferralGroups = UserReferralData.GetCompletedReferrals();
        }

        
        activate();
        
        function activate() {
            //logger.info('Activated referral View');
            //logger.info($stateParams.Category);
            $rootScope.ShowCrumbs = true;
            $rootScope.ShowPracticeCrumb = false;
        }

        function SectionClick(category) {
            $state.go('category', { Type: ReferralType, Category: category })
        }

    }
})();


